<div id="wrap">
  <div class="module">
    <h1>Listing Books</h1>

    <%= form_tag books_path, :method => 'get' do %>
      <%= hidden_field_tag :direction, params[:direction] %>
      <%= hidden_field_tag :sort, params[:sort] %>
      <p>
        <%= text_field_tag :search, params[:search], :id => "search_field" %>
        <%= submit_tag "Search", :name => nil %>
        <%= link_to "Clear", books_path %>
      </p>
    <% end %>
    
    <table class="books">
      <tr>
        <th><%= sortable "title" %></th>
        <th><%= sortable "cover_type", "Cover Type" %></th>
        <th><%= sortable "author_id", "Author" %></th>
        <th>ISBN</th>
        <th></th>
        <th></th>
        <th></th>
      </tr>

    <% @books.each do |book| %>
      <tr>
        <td><%= book.title %></td>
        <td><%= book.cover_type %></td>
        <td><%= book.author.full_name %></td>
        <td>
          <% if book.has_isbn %>
            <%= book.isbn  %>
          <% else %>
            <span class="unverified-isbn"><%= book.isbn %> </span>
          <% end %>
        </td>
        <td><%= link_to 'Show', book %></td>
        <td><%= link_to 'Edit', edit_book_path(book) %></td>
        <td><%= link_to 'Destroy', book, :confirm => 'Are you sure?', 
                                          :method => :delete %></td>
      </tr>
    <% end %>
    </table>
    <%= will_paginate @books %>

    <br />

    <%= link_to 'New Book', new_book_path, :class => 'more' %>
  </div>
</div>